package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collections;

class zbor {
   public static Object a(Object[][] var0, Object[][] var1, boolean var2) {
      Object[][] var3 = new Object[var1.length][];
      int var4 = var1[0].length;

      for(int var5 = 0; var5 < var1.length; ++var5) {
         var3[var5] = new Object[var4];

         for(int var6 = 0; var6 < var4; ++var6) {
            Object var7 = var1[var5] == null ? null : var1[var5][var6];
            if (var7 instanceof Double) {
               var3[var5][var6] = a(var0, var7, var2);
            } else {
               var3[var5][var6] = zst.f;
            }
         }
      }

      return var3;
   }

   public static Object a(Object[][] var0, Object var1, boolean var2) {
      int var3 = var2 ? (int)com.aspose.cells.a.c.zi.b(var1) : (int)Math.ceil(com.aspose.cells.a.c.zi.b(var1));
      if (var3 <= 0) {
         return zst.f;
      } else {
         Object[] var4 = var0[0];
         ArrayList var5 = new ArrayList();

         for(int var6 = 0; var6 < var0.length; ++var6) {
            if (var0[var6] != null) {
               for(int var7 = 0; var7 < var4.length; ++var7) {
                  Object var8 = var0[var6][var7];
                  if (var8 instanceof Double) {
                     com.aspose.cells.b.a.a.ze.a(var5, var8);
                  }
               }
            }
         }

         Collections.sort(var5);
         if (var3 > var5.size()) {
            return zst.f;
         } else if (var2) {
            return var5.get(var3 - 1);
         } else {
            return var5.get(var5.size() - var3);
         }
      }
   }

   public static Object a(int var0, int var1, double var2, boolean var4) {
      boolean var6 = true;
      boolean[] var7 = new boolean[]{var6};
      Object var5 = zbop.a(var0, var1, var2, var4, var7);
      var6 = var7[0];
      if (var6) {
         var5 = "#NUM!";
      }

      return var5;
   }

   public static Object a(double var0, double var2, boolean var4) {
      boolean var6 = true;
      boolean[] var7 = new boolean[]{var6};
      Object var5 = zbop.a(var0, var2, var4, var7);
      var6 = var7[0];
      if (var6) {
         var5 = "#NUM!";
      }

      return var5;
   }

   static double a(int var0, double var1, boolean var3) {
      double var4;
      if (var3) {
         if (var0 == 0) {
            return Math.exp(-var1);
         } else {
            var4 = 1.0D;
            double var11 = 1.0D;
            double var8 = 1.0D;

            for(int var10 = 1; var10 <= var0; ++var10) {
               var4 *= (double)var10;
               var11 *= var1;
               var8 += var11 / var4;
            }

            return var8 / Math.exp(var1);
         }
      } else {
         var4 = (double)var0;
         if (var0 == 0) {
            var4 = 1.0D;
         } else {
            for(int var6 = var0 - 1; var6 > 1; --var6) {
               var4 *= (double)var6;
            }
         }

         return zbc.a(var1, var0) / (Math.exp(var1) * var4);
      }
   }

   static Object a(double var0, double var2, double var4, double var6, double var8) {
      boolean var11 = true;
      if (var0 >= var6 && var0 <= var8 && var8 > var6 && var2 > 0.0D && var4 > 0.0D) {
         boolean[] var12 = new boolean[]{var11};
         Object var10 = zbop.a(var0, var2, var4, var6, var8, var12);
         var11 = var12[0];
         if (var11) {
            var10 = "#NUM!";
         }

         return var10;
      } else {
         return "#NUM!";
      }
   }

   static Object b(double var0, double var2, double var4, double var6, double var8) {
      boolean var11 = true;
      boolean[] var12 = new boolean[]{var11};
      Object var10 = zbop.b(var0, var2, var4, var6, var8, var12);
      var11 = var12[0];
      if (var11) {
         var10 = "#NUM!";
      }

      return var10;
   }

   static Object a(double var0, double var2, double var4, boolean var6) {
      Object var7 = zbop.a(var0, var2, var4, var6);
      if (Double.isNaN((Double)var7)) {
         var7 = "#NUM!";
      }

      return var7;
   }

   static Object a(double var0, double var2, double var4) {
      Object var6 = zbop.c(var0, var2, var4);
      if (Double.isNaN((Double)var6)) {
         var6 = "#NUM!";
      }

      return var6;
   }

   static Object a(double var0, double var2, int var4) {
      boolean var6 = true;
      boolean[] var7 = new boolean[]{var6};
      Object var5 = zbop.a(var0, (double)((long)var2), var4, var7);
      var6 = var7[0];
      if (var6) {
         var5 = "#NUM!";
      }

      return var5;
   }

   static Object a(double var0, double var2) {
      boolean var5 = true;
      boolean[] var6 = new boolean[]{var5};
      Object var4 = zbop.a(var0, (double)((long)var2), var6);
      var5 = var6[0];
      if (var5) {
         var4 = "#NUM!";
      }

      return var4;
   }

   static Object b(double var0, double var2) {
      if (var0 >= 0.0D && var2 >= 1.0D && var2 <= 1.0E10D) {
         boolean var5 = true;
         boolean[] var6 = new boolean[]{var5};
         Object var4 = zbop.b(var0, (double)((long)var2), var6);
         var5 = var6[0];
         if (var5) {
            var4 = "#NUM!";
         }

         return var4;
      } else {
         return "#NUM!";
      }
   }

   static Object c(double var0, double var2) {
      boolean var5 = true;
      boolean[] var6 = new boolean[]{var5};
      Object var4 = zbop.c(var0, (double)((long)var2), var6);
      var5 = var6[0];
      if (var5) {
         var4 = "#NUM!";
      }

      return var4;
   }

   static Object b(double var0, double var2, double var4) {
      boolean var7 = true;
      boolean[] var8 = new boolean[]{var7};
      Object var6 = zbop.b(var0, (double)((long)var2), (double)((long)var4), var8);
      var7 = var8[0];
      if (var7) {
         var6 = "#NUM!";
      }

      return var6;
   }

   static Object c(double var0, double var2, double var4) {
      boolean var7 = true;
      boolean[] var8 = new boolean[]{var7};
      Object var6 = zbop.c(var0, (double)((long)var2), (double)((long)var4), var8);
      var7 = var8[0];
      if (var7) {
         var6 = "#NUM!";
      }

      return var6;
   }

   private static Object a(Object var0, boolean var1, boolean var2) {
      ArrayList var3 = new ArrayList();
      Object[] var4 = (Object[])((Object[])var0);

      for(int var5 = 0; var5 < var4.length; ++var5) {
         Object[] var6 = (Object[])((Object[])com.aspose.cells.b.a.za.a(var4, var5));
         if (var6 != null) {
            for(int var7 = 0; var7 < var6.length; ++var7) {
               Object var8 = com.aspose.cells.b.a.za.a(var6, var7);
               if (var8 != null) {
                  if (!var2 && var8 instanceof zst) {
                     return var8;
                  }

                  switch(zamo.a(var8.getClass())) {
                  case 14:
                     com.aspose.cells.b.a.a.ze.a(var3, var8);
                  case 15:
                  case 17:
                  case 18:
                  default:
                     break;
                  case 16:
                     com.aspose.cells.b.a.a.ze.a(var3, (Object)CellsHelper.getDoubleFromDateTime((DateTime)var8, var1));
                  }
               }
            }
         }
      }

      Collections.sort(var3);
      return var3;
   }

   static Object a(ArrayList var0, double var1) {
      double var3 = (double)(var0.size() - 1) * var1;
      int var5 = (int)var3;
      double var6 = var3 - (double)var5;
      return var6 == 0.0D ? var0.get(var5) : (1.0D - var6) * (Double)var0.get(var5) + var6 * (Double)var0.get(var5 + 1);
   }

   static Object a(Object var0, Object var1, WorkbookSettings var2, boolean var3) {
      if (var0 == null) {
         return "#NUM!";
      } else {
         double var4;
         switch(zamo.a(var0.getClass())) {
         case 3:
         case 18:
            return "#NUM!";
         case 14:
            if (var1 != null) {
               var1 = zyn.e(var1, var2.getDate1904());
               if (var1 instanceof Double) {
                  var4 = (Double)var1;
                  if (var4 >= 0.0D && var4 <= 1.0D) {
                     return var0;
                  }

                  return "#NUM!";
               }

               return var1;
            }

            return var0;
         case 16:
            if (var1 != null) {
               var1 = zyn.e(var1, var2.getDate1904());
               if (var1 instanceof Double) {
                  var4 = (Double)var1;
                  if (var4 >= 0.0D && var4 <= 1.0D) {
                     return CellsHelper.getDoubleFromDateTime((DateTime)var0, var2.getDate1904());
                  }

                  return "#NUM!";
               }

               return var1;
            }

            return CellsHelper.getDoubleFromDateTime((DateTime)var0, var2.getDate1904());
         default:
            if (com.aspose.cells.a.c.zc.a(var0)) {
               var4 = 0.0D;
               if (var1 != null) {
                  var1 = zyn.e(var1, var2.getDate1904());
                  if (!(var1 instanceof Double)) {
                     return var1;
                  }

                  var4 = (Double)var1;
               }

               if (var4 >= 0.0D && var4 <= 1.0D) {
                  Object var6 = a(var0, var2.getDate1904(), var3);
                  if (var6 instanceof zst) {
                     return var6;
                  } else if (var6 instanceof String) {
                     return var6;
                  } else {
                     ArrayList var7 = (ArrayList)var6;
                     return var7.size() == 0 ? "#NUM!" : a(var7, var4);
                  }
               } else {
                  return "#NUM!";
               }
            } else {
               return "#NUM!";
            }
         }
      }
   }

   static Object b(Object var0, Object var1, WorkbookSettings var2, boolean var3) {
      if (var0 == null) {
         return "#NUM!";
      } else {
         switch(zamo.a(var0.getClass())) {
         case 3:
         case 18:
            return "#NUM!";
         case 14:
            return var0;
         case 16:
            return CellsHelper.getDoubleFromDateTime((DateTime)var0, var2.getDate1904());
         default:
            if (com.aspose.cells.a.c.zc.a(var0)) {
               double var4 = 0.0D;
               if (var1 != null) {
                  var1 = zyn.e(var1, var2.getDate1904());
                  if (!(var1 instanceof Double)) {
                     return var1;
                  }

                  var4 = (Double)var1;
               }

               if (var4 >= 0.0D && var4 <= 4.0D) {
                  Object var6 = a(var0, var2.getDate1904(), var3);
                  if (var6 instanceof zst) {
                     return var6;
                  } else if (var6 instanceof String) {
                     return var6;
                  } else {
                     ArrayList var7 = (ArrayList)var6;
                     if (var7.size() == 0) {
                        return "#NUM!";
                     } else {
                        switch((int)var4) {
                        case 0:
                           return var7.get(0);
                        case 1:
                           return a(var7, 0.25D);
                        case 2:
                           return a(var7, 0.5D);
                        case 3:
                           return a(var7, 0.75D);
                        case 4:
                           return var7.get(var7.size() - 1);
                        default:
                           return "#NUM!";
                        }
                     }
                  }
               } else {
                  return "#NUM!";
               }
            } else {
               return "#NUM!";
            }
         }
      }
   }
}
